#include <iostream>
#include <algorithm>
#include <string>
using namespace std;


int main()
{
    string pattern;
    int n;
    cin >> n;
    while(n--)
    {
        cin >> pattern;
        if((pattern[pattern.size() - 1] - '0') % 2 == 0)
        {
            cout << pattern << endl;
            continue;
        }
        // if(pattern.size() == 1 && pattern[0] == '0')
        // {
        //     cout << 0 << endl;
        //     continue;
        // }

        bool ok = false;
        for(auto it = pattern.begin(); it != pattern.end(); it++)
        {
            if((*it - '0') % 2 == 0)
            {
                std::swap(*it, *(pattern.end() - 1));
                cout << pattern << endl;
                ok = true;
                break;
            }
        }
        if(ok == false)
        {
            cout<< -1 << endl;
        }
    }
    return 0;
}